package com.demo.server.util;

import java.io.Serializable;

import com.demo.server.constant.CodeMsg;


public class Result implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Integer code;
    private String msg;
    
	public Integer getCode() {
		return code;
	}
	public void setCode(Integer code) {
		this.code = code;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	
	public Result() {
		super();
		// TODO Auto-generated constructor stub
	}
	public Result(Integer code, String msg) {
		super();
		this.code = code;
		this.msg = msg;
	}
    
	public Result(CodeMsg codeMsg) {
		super();
		this.code = codeMsg.getCode();
		this.msg = codeMsg.getMsg();
	}
    
	public static Result result(CodeMsg codeMsg) {
		return new Result(codeMsg);
	}
	
	public static Result success() {
		return new Result(CodeMsg.SUCCESS);
	}
    
	public static Result success(String msg) {
		return new Result(CodeMsg.SUCCESS.getCode(),msg);
	}
	
	public static Result fail() {
		return new Result(CodeMsg.FAILURE);
	}
    
	public static Result fail(String msg) {
		return new Result(CodeMsg.FAILURE.getCode(),msg);
	}
}
